package com.xhui.vimarket.common.utils.context;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.xhui.vimarket.common.utils.springplus.ApplicationContextUtil;

public class ComtextLoadListenerManager extends ContextLoaderListener implements
		ServletContextListener {
	private ServletContext context;
	private WebApplicationContext webApplicationContext;

	public void contextInitialized(ServletContextEvent event) {
			super.contextInitialized(event);
			
			this.context = event.getServletContext();   
			this.webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(context);   
			this.context.setAttribute("WEBAPPLICATIONCONTEXT", webApplicationContext);
			WebApplicationContext webApplicationContext = (WebApplicationContext)this.context.getAttribute("WEBAPPLICATIONCONTEXT");
			ApplicationContextUtil aplicationContextUtil = (ApplicationContextUtil)webApplicationContext.getBean("applicationContextUtil");
	}
}
